package net.zjitc.lib.Synchronized;

/**
 * @author 朱志文
 * @data 2019/10/22 0022
 */
public class MyThreadSynchronized {
    private int count;
    public void chese(int num) {
        if (num == 0) {
            Work();
        } else if (num == 1) {
            Work2();
        } else {
            Work3();
        }
    }

    public synchronized void Work() {
        System.out.println("运行线程Name：" + Thread.currentThread().getName());
        System.out.println("结束线程Name：" + Thread.currentThread().getName());
    }

    public synchronized void Work2() {
        System.out.println("运行线程Name2：" + Thread.currentThread().getName());
        System.out.println("结束线程Name2：" + Thread.currentThread().getName());
    }

    public synchronized void Work3() {
        System.out.println("运行线程Name3：" + Thread.currentThread().getName());
        System.out.println("结束线程Name3：" + Thread.currentThread().getName());
    }
    public synchronized void increase(){
        for (int i = 0; i <5000 ; i++) {
            count++;
            System.out.println(Thread.currentThread().getName()+","+count);
        }
    }
    public void getCount(){
        System.out.println(count);
    }
}
